'use strict';

const Service = require('egg').Service;

class TestService extends Service {
  async author(test) {
    const application = await this.app.model.Applications.findOne({
      where: {
        test,
      },
    });
    if (application) {
      await this.service.application.initVisitor(application.id);
      return { code: application.code,
        alias: `app/${application.code}`,
        code_id: application.id,
      };
    }
    throw new Error('不存在的测试账号');

  }
}

module.exports = TestService;
